﻿using System.Linq;
using System.Web.Mvc;
using ControleRepresentante.Logic.Models;
using Telerik.Web.Mvc.UI.Fluent;

namespace WebSite.ViewModels.EditViewModels.EditGridViewModels
{
    public class ContatoEditGridViewModel : EditGridViewModel<ContatoViewModel>
    {
        public ContatoEditGridViewModel(HtmlHelper htmlHelper, string controllerName, DetailsHolder detailsHolder)
            : base(htmlHelper, "Contato", controllerName, detailsHolder.Contatos.Select(x => new ContatoViewModel(x)))
        {
        }

        protected override void Columns(GridColumnFactory<ContatoViewModel> configurator)
        {
            configurator.Bound(contato => contato.Tipo);
            configurator.Bound(contato => contato.Valor);
            configurator.Bound(contato => contato.Observacao);
            configurator.Bound(contato => contato.Principal)
                .ClientTemplate("<input type='checkbox' disabled='disabled' <#=Principal? checked='checked' : '' #> />");
        }
    }
}